package com.guihuo.mq.active;

/**
 * 项目名称：middleware-learning
 * 类名称：ConsumerMain
 * 类描述：ConsumerMain
 * 创建时间：2019/1/10
 *
 * @author guihuo   (E-mail:1620657419@qq.com)
 * @version v1.0
 */
public class ConsumerMain {

    public static void main(String[] args){
        Comsumer comsumer = new Comsumer();
        comsumer.init();
        ConsumerMain testConsumer = new ConsumerMain();
        new Thread(testConsumer.new ConsumerMq(comsumer)).start();
        new Thread(testConsumer.new ConsumerMq(comsumer)).start();
        new Thread(testConsumer.new ConsumerMq(comsumer)).start();
        new Thread(testConsumer.new ConsumerMq(comsumer)).start();
    }

    private class ConsumerMq implements Runnable{
        Comsumer comsumer;
        public ConsumerMq(Comsumer comsumer){
            this.comsumer = comsumer;
        }

        @Override
        public void run() {
            while(true){
                try {
                    comsumer.getMessage("guihuo");
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }



}
